package com.cxria.script.upload.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "videoInfo")
class VideoInfo implements Serializable {
    @Id
    @ManyToOne
    @JsonBackReference
    @JoinColumn(name = "videoId")
    Video video;
    @Column
//    @ApiModelProperty("每秒传输帧数")
    double fps;
    @Column
//    @ApiModelProperty("视频时长")
    double duration;
    @Column
//    @ApiModelProperty("ufop定义的分辨率")
    double resolution;
    @Column
//    @ApiModelProperty("档次")
    String profile;
    @Column
//    @ApiModelProperty("级别")
    String level;
    @Column
//    @ApiModelProperty("宽")
    int width;
    @Column
//    @ApiModelProperty("高")
    int height;
    @Column
//    @ApiModelProperty("颜色空间")
    String colorSpace;
    @Column
//    @ApiModelProperty("像素格式")
    String pixelFormat;
    @Column
//    @ApiModelProperty("display aspect ratio")
    String dar;
    @Column
//    @ApiModelProperty("sample aspect ratio")
    String sar;
    @Column
//    @ApiModelProperty("位深度")
    int bits;
    @Column
//    @ApiModelProperty("起始时间")
    double startTime;
    @Column
//    @ApiModelProperty("比特率")
    int bitRate;
    @Column
//    @ApiModelProperty("总帧数")
    int frames;
    @Column
//    @ApiModelProperty("帧率")
    String frameRate;
    @Column
//    @ApiModelProperty("视频编解码全名")
    String codecLongName;
    @Column
//    @ApiModelProperty("视频编解码名")
    String codecName;
    @Column
//    @ApiModelProperty("源视频HDR类型")
    String sourceDynamicRange;

    @Override
    boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        VideoInfo videoInfo = (VideoInfo) o;
        return Double.compare(videoInfo.fps, fps) == 0 &&
                Double.compare(videoInfo.duration, duration) == 0 &&
                Double.compare(videoInfo.resolution, resolution) == 0 &&
                width == videoInfo.width &&
                height == videoInfo.height &&
                bits == videoInfo.bits &&
                Double.compare(videoInfo.startTime, startTime) == 0 &&
                bitRate == videoInfo.bitRate &&
                frames == videoInfo.frames &&
                Objects.equals(video, videoInfo.video) &&
                Objects.equals(profile, videoInfo.profile) &&
                Objects.equals(level, videoInfo.level) &&
                Objects.equals(colorSpace, videoInfo.colorSpace) &&
                Objects.equals(pixelFormat, videoInfo.pixelFormat) &&
                Objects.equals(dar, videoInfo.dar) &&
                Objects.equals(sar, videoInfo.sar) &&
                Objects.equals(frameRate, videoInfo.frameRate) &&
                Objects.equals(codecLongName, videoInfo.codecLongName) &&
                Objects.equals(codecName, videoInfo.codecName) &&
                Objects.equals(sourceDynamicRange, videoInfo.sourceDynamicRange);
    }

    @Override
    int hashCode() {
        return Objects.hash(video, fps, duration, resolution, profile, level, width, height, colorSpace, pixelFormat, dar, sar, bits, startTime, bitRate, frames, frameRate, codecLongName, codecName, sourceDynamicRange);
    }
}
